<template>
	<view class="contanner">
		<view class="top">
			<u-navbar height="50" back-icon-color="#fff" title="我的积分" title-color="#fff" title-size="36"
				:border-bottom="false" :background="bgStyle"></u-navbar>
		</view>
		<view class="hhh" style="height: 300rpx;width: 750rpx;">
			
		</view>
		<view class="bg">
			<image src="/static/img/bg1.png"
				mode="widthFix" style="width: 750rpx;"></image>
			<view class="Mypoint">
				<view class="point">
					{{point}}
				</view>
				<view class="title">
					我的账户积分
				</view>
			</view>
		</view>
		<view class="billList">
			<u-tabs :list="list" :is-scroll="false" v-model="current" @change="change" active-color="#FF432EFF"></u-tabs>
			<view class="cell" v-for="(item,index) in billsList" :key="index" v-if="current==0">
				<view class="left">
					<view class="title">
						{{item.remark}}
					</view>
					<view class="time">
						item.crtime
					</view>
				</view>
				<view class="right">
					<view class="point">
						<span class="add" >{{item.points}}积分</span>
						<!-- <span class="reduce" v-if="item.type==1">-{{item.amount}}积分</span> -->
					</view>
				</view>
			</view>
			<view class="rules" v-if="current==1">
				<u-parse :html="rules" :selectable="true" :tag-style="style"></u-parse>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getPointDetail,
		getAccountInfo,
	} from '@/api/user.js'
	import {
		getpointRule
	}from '/common/pointStore.js'
	export default {
		data() {
			return {
				point:"",
				billsList: [],
				bgStyle: {
					background: "transparent"
				},
				list: [{
					name: '积分明细'
				}, {
					name: '积分规则'
				}],
				current: 0,
				rules:"",
				style:{
					p: 'color: red;font-size:32rpx',
				}
			};
		},
		mounted() {
			this.getTcashlog()
		},
		methods: {
			getTcashlog() {
				getPointDetail().then((res) => {
					console.log("账单", res);
					this.billsList = res.list
				})
				getpointRule().then(res=>{
					console.log("积分规则",res);
					this.rules = res.data
				})
				getAccountInfo().then(res=>{
					console.log("账户",res);
					this.point = res.data.points
				})
			},
			earningtips() {
				uni.navigateTo({
					url: '/page/earning-tip/earning-tip'
				})
			},
		
			change(index) {
				this.current =index
			}
		}
	}
</script>

<style lang="scss" scoped>
	.contanner {
		min-height: 100vh;
		min-width: 100vw;
		background-color: #f5f5f5;
		font-family: Source Han Sans CN;
		font-weight: 400;
	}
	.rules{
		background-color: #fff;
		width: 750rpx;
		box-sizing: border-box;
		padding: 20rpx;
	}

	.bg {
		position: absolute;
		top: 0;
		height: 500rpx;

		.Mypoint {
			width: 300rpx;
			height: 100rpx;
			position: absolute;
			top: calc(50% - 50rpx);
			left: calc(50% - 150rpx);
			text-align: center;
			color: #fff;
			display: flex;
			flex-direction: column;
			justify-content: space-between;

			.point {
				font-size: 44rpx;
			}
		}
	}
	.billList{
		z-index: 999;
	}
	.cell{
		width: 750rpx;
		height: 100rpx;
		box-sizing: border-box;
		padding: 20rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		.left{
			display: flex;
			justify-content: space-between;
			.time{
				font-size: 22rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #666666;
			}
			.title{
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #333333;
			}
		}
		.right{
			.add{
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #FF3B30;
			}
			.reduce{
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #01A90C;
			}
		}
	}
</style>